﻿//Copyright (c) 2010, Andreas Grünwald
//All rights reserved.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace yaTDL.Core.MVVM
{
    public class ViewModelBase:NotifyObject
    {
        public event EventHandler Closed;

        public bool IsShown { get; set; }

        public Action CloseViewAction { get; set; }

        public void CloseView()
        {
            if (CloseViewAction != null)
            {
                CloseViewAction();
                IsShown = false;
                OnClosed();
            }
        }

        private void OnClosed()
        {
            if (this.Closed != null)
            {
                Closed(this, EventArgs.Empty);
            }
        }
    }
}
